package com.jic.manager.controller.manage.merchant;


import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.manager.entity.Channel;
import com.jic.manager.request.ChannelRequest;
import com.jic.manager.request.MeentryTermsRequest;
import com.jic.manager.service.ChannelService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商家控制器
 * @autho wwb
 */
@RestController
@RequestMapping("channel")
public class ChannelController {
    @Autowired
    private ChannelService mChannelService;
    //查询列表
    @PostMapping(value = "/queryChannelInfo")
    public RestResult<Channel> queryInfo(@RequestBody Channel channel){
        Channel channelVo  = mChannelService.queryByPrimaryKey(channel.getId());
        return RestResult.success(channelVo);
    }

    //查询列表
    @PostMapping(value = "/queryChannelListOther")
    public RestResult<List<Channel>> queryChannelListOther(@RequestBody Channel channel){
        List<Channel> channels  = mChannelService.query(channel);
        return RestResult.success(channels);
    }

    //分页查询
    @PostMapping(value = "/queryChannelList")
    public RestResult<PageResult<Channel>> queryChannelList(@RequestBody ChannelRequest channelRequest){
        PageResult<Channel> channelPageResult = mChannelService.queryPage(channelRequest);
        return RestResult.success(channelPageResult);
    }

    //编辑方法
    @PostMapping(value = "/editChannelInfo")
    public RestResult editMerchantInfo(@RequestBody ChannelRequest channelRequest){
        System.out.println();
        System.out.println();
        System.out.println(channelRequest.toString());
        System.out.println();
        System.out.println();
        return mChannelService.editMerchantInfo(channelRequest);
    }
    //删除方法
    @PostMapping(value = "deleteChannelInfo")
    public RestResult<String> deleteDept(@RequestBody ChannelRequest channelRequest){
        mChannelService.delete(channelRequest);
        return RestResult.success("成功");
    }
}
